#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

struct student
{
    string name;
    int score;
};

int avg(student allStduent[])
{
    int result=0;
    int i=0;
    for(;allStduent[i].score!=-1;i++)
        result+=allStduent[i].score;
    return result/(i+1);
}

void outputAvg(student allStudent[])
{
    int avgnum=avg(allStudent);
    printf("avg:%d\n",avgnum);
    printf("above avg student:\n");
    int num=0;
    for(int i=0;allStudent[i].score!=-1;i++)
    {
        if(allStudent[i].score>avgnum)
        {
            cout<<allStudent[i].name<<endl;
            num++;
        }
    }
    printf("num:%d\n",num);
}

void outputFail(student allStudent[])
{
    printf("Fail student:\n");
    int num=0;
    for(int i=0;allStudent[i].score!=-1;i++)
    {
        if(allStudent[i].score<60)
        {
            cout<<allStudent[i].name<<endl;
            num++;
        }
    }
    printf("num:%d\n",num);
}

bool inInterval(int score,int min,int max)
{
    return (score>min)&&(score<=max);
}

void outputInterval(student allStudent[],int min,int max)
{
    int num=0;
    int i=0;
    for(;allStudent[i].score!=-1;i++)
    {
        if(inInterval(allStudent[i].score,min,max))
            num++;
    }
    printf("%d-%d ",min,max);
    printf("rate is:%f\n",(float)num/(i+1));
}

void outputAllInterval(student allStudent[],int statinter[])
{
    int min=statinter[0];
    int max=statinter[1];
    int nowsub=1;
    for(int i=0;i<20;i++)
    {
        outputInterval(allStudent,min,max);
        //next
        min=statinter[nowsub];
        max=statinter[nowsub+1];
        nowsub++;
        //end
        if(min==100)
            break;
    }
}

int main()
{
    student allStudent[30];
    for(int i=0;i<30;i++)
    {
        cin>>allStudent[i].score;
        if(allStudent[i].score==-1)
            break;
        cin>>allStudent[i].name;
    }

    outputAvg(allStudent);
    outputFail(allStudent);

    int statinter[20];
    statinter[0]=0;
    printf("set statistical interval of score(100 is end):\n");
    for(int i=1;i<20;i++)
    {
        cin>>statinter[i];
        if(statinter[i]==100)
            break;
    }
    outputAllInterval(allStudent,statinter);
}
